package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingLevelServiceImpl  implements NursingLevelService {

    @Autowired
    private NursingLevelMapper nursingLevelMapper;
    @Override
    public List<NursingLevelVo> getAllNursingLevel() {
        return nursingLevelMapper.getAllNursingLevel();
    }

    @Override
    public PageResponse<NursingLevelVo> getNursingLevelList(NursingLevelDto nursingLevelDto) {
        PageHelper.startPage(nursingLevelDto.getPageNum(), nursingLevelDto.getPageSize());
        Page<NursingLevelVo> pageList = nursingLevelMapper.getNursingLevelList(nursingLevelDto);
        return PageResponse.of(pageList,NursingLevelVo.class);
    }

    @Override
    public NursingLevelVo getNursingLevelById(Long id) {
        return nursingLevelMapper.getNursingLevelById(id);
    }

    @Override
    public void deleteNursingLevelById(Long id) {
        nursingLevelMapper.deleteNursingLevelById(id);
    }

    @Override
    public void updateNursingLevelStatus(Long id, Integer status) {
        nursingLevelMapper.updateNursingLevelStatus(id,status);
    }

    @Override
    public void addNursingLevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel = BeanUtil.copyProperties(nursingLevelDto, NursingLevel.class);
        nursingLevelMapper.addNursingLevel(nursingLevel);
    }

    @Override
    public void updateNursingLevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel = BeanUtil.copyProperties(nursingLevelDto, NursingLevel.class);
        nursingLevelMapper.updateNursingLevel(nursingLevel);
    }
}
